Crate egui_commonmark

source
Expand description

A commonmark viewer for egui

§Example

let markdown =
r"# Hello world

* A list
* [ ] Checkbox
";

let mut cache = CommonMarkCache::default();
CommonMarkViewer::new().show(ui, &mut cache, markdown);

Remember to opt into the image formats you want to use!

image = { version = "0.25", default-features = false, features = ["png"] }

By default egui does not show urls when you hover hyperlinks. To enable it, you can do the following before calling any ui related functions:

ui.style_mut().url_in_tooltip = true;

§Compile time evaluation of markdown

If you want to embed markdown directly the binary then you can enable the macros feature. This will do the parsing of the markdown at compile time and output egui widgets.

§Example

use egui_commonmark::{CommonMarkCache, commonmark};
let mut cache = CommonMarkCache::default();
let _response = commonmark!(ui, &mut cache, "# ATX Heading Level 1");

Alternatively you can embed a file

§Example

use egui_commonmark::{CommonMarkCache, commonmark_str};
let mut cache = CommonMarkCache::default();
commonmark_str!(ui, &mut cache, "content.md");

For more information check out the documentation for egui_commonmark_macros

§Features

  • macros — Enable proc macros for compile time generation of egui widgets from markdown
  • nightly — Builds upon the macros feature. Enables tracking of markdown files to recompile when their content changes. Uses nightly features
  • pulldown_cmark (enabled by default) — No-op feature
  • better_syntax_highlighting — Syntax highlighting for code blocks using syntect
  • load-images (enabled by default) — Enable loading of images. Make sure to also opt in to what image format you need through the image crate.
  • svg — Support loading svg images
  • fetch — Images with urls will be downloaded and displayed

Macros§

Structs§